      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          <ul class="nav nav-tabs mytabs">
		  	 <li  class="active"><a href="<?php echo site_url('school/classindex/id/'.$id)?>">班级列表</a></li>
		  	 <li><a href="<?=site_url()?>/school/index">学校列表</a></li>
		  </ul>
		  <div class="row margin-bottom-30">
            <div class="col-md-12">
            	<select id="grade">
                   	<?php foreach ($grades as $item):?>
                   		<option value="<?php echo $item['id'];?>"><?php echo $item['name'];?></option>
                     <?php endforeach;?>
                </select>
                <input type="text" id="num" name="num" value="" placeholder="请输入班级数量">
                <input type="hidden" id="school" name="school" value="<?php echo $id;?>">
                <button class="btn btn-primary" id="submit_btn">添加</button>
            </div>
          </div> 
          <div class="row">
            <div class="col-md-12">
              <div class="table-responsive">
                <table class="table table-striped table-hover table-bordered">
                  <thead>
                    <tr>
                      <th>ID</th>
                      <th>学校名称</th>
                      <th>年级</th>
                      <th>班级</th>
                      <th>操作</th>
                    </tr>
                  </thead>
                  <tbody>
                  	<?php foreach ($classes as $item):?>
                    <tr>
                      <td><?php echo $item['id'];?></td>
                      <td><?php echo $item['sname'];?></td>
                      <td><?php echo $item['gname'];?></td>
                      <td><?php echo $item['name'];?></td>
                      <td>
                      	    <a href="#" class="del" data-id="<?php echo $item['id'];?>" >删除</a>
                      </td>
                    </tr>
                    <?php endforeach;?>
                  </tbody>
                </table>
              </div>
              <div class="pagination">
           		 <?php echo $links ;?>
         	 </div>
            </div>
          </div>
        </div>
      </div>
<script>
	$(document).ready(function() {
		$("#submit_btn").click(function() {
			var school = $("#school").val();
			var grade = $("#grade").val();
			var num = $("#num").val();
			$.ajax({
				url : '<?php echo site_url('school/addclass')?>',
				type : "post",
				async : false,
				data : {
					'school':school,
					'grade':grade,
					'num':num
				},
				dataType : "json",
				success : function(data) {
					if(data.code)
					{
						alert(data.msg);
						window.location.reload();
					}else{
						alert(data.msg);
					}
				}
			});
		});
		
		
		$(".del").click(function() {
			if(confirm("确定要删除该班级吗？"))
			{
				var id = $(this).attr("data-id");
				$.ajax({
					url : '<?php echo site_url('school/deleteclass')?>',
					type : "post",
					async : false,
					data : {
						'id' : id
					},
					dataType : "json",
					success : function(data) {
						if(data.code)
						{
							alert(data.msg);
							window.location.reload();
						}else{
							alert(data.msg);
						}
					}
				});
			}
		});
	}); 
</script>